package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_DaChiZi
 * Date: 2025/6/20
 * Time: 12:06
 */


class SingleLazy {

    public static final Object locker = new Object();

    private static volatile SingleLazy instance = null;
    public static SingleLazy getInstance() {
        if (instance == null) {
            synchronized (locker) {
                if (instance == null) {
                    instance = new SingleLazy();
                }
            }
        }
        return instance;
    }

    public SingleLazy() {
    }
    //    private SingleLazy() { }
}

public class Demo29 {
    public static void main(String[] args) {
        SingleLazy s1 = SingleLazy.getInstance();
        SingleLazy s2 = SingleLazy.getInstance();
        System.out.println(s1==s2);
    }
}
